package priv.bruce.servlet;

import java.io.IOException;
import java.util.HashMap;
import java.util.Map;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.alibaba.fastjson.JSON;

import priv.bruce.service.Comment4DetailByZanDescService;


public class FindComment4DetailByZanDescServlet extends HttpServlet {
	
	private static final long serialVersionUID = 1L;
	
	private Comment4DetailByZanDescService comment4DetailByZanDescService = new Comment4DetailByZanDescService();

	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		response.setContentType("application/json;charset=utf-8");
		int id = Integer.parseInt(request.getParameter("id"));
		try {
			Map<String, Object> comments = new HashMap<>();
			comments.putAll(comment4DetailByZanDescService.findCommentByZan(id));
			response.getWriter().append(JSON.toJSONString(comments));
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
	
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		response.setContentType("application/json;charset=utf-8");
		int id = Integer.parseInt(request.getParameter("id"));
		try {
			Map<String, Object> comments = new HashMap<>();
			comments.putAll(comment4DetailByZanDescService.findCommentByZan(id));
			response.getWriter().append(JSON.toJSONString(comments));
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
}
